package com.chuanyang.driverh.mainmy.adapter;

import android.content.Context;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;

import com.chuanyang.driverh.R;
import com.chuanyang.driverh.base.BaseListAdapter;
import com.chuanyang.driverh.responseresult.LinesManageData;
import com.chuanyang.driverh.utils.StringUtil;

import java.util.List;


/**
 * 司机的常用路线
 */
public class CommonLineAdapter extends BaseListAdapter<LinesManageData.DataBean> {
    public void setObjects(List<LinesManageData.DataBean> objects)
    {
        this.objects = objects;
    }

    private List<LinesManageData.DataBean> objects;
    private Context context;
    private ViewHolder viewHolder;

    public CommonLineAdapter(Context context, List<LinesManageData.DataBean> objects) {
        super(context, objects);
        this.context = context;
        this.objects = objects;
    }

    @Override
    public View getZkView(int position, View convertView, ViewGroup parent) {
        if (convertView == null) {
            convertView = View.inflate(context, R.layout.my_item_mycarteamline, null);
            viewHolder = new ViewHolder();
            viewHolder.tv_lines_sort = (TextView) convertView.findViewById(R.id.tv_lines_sort);
            viewHolder.tv_lines_staadd = (TextView) convertView.findViewById(R.id.tv_lines_staadd);
            viewHolder.tv_lines_endadd = (TextView) convertView.findViewById(R.id.tv_lines_endadd);
           // viewHolder.tv_lines_totaldistance = (TextView) convertView.findViewById(R.id.tv_lines_totaldistance);
            convertView.setTag(viewHolder);
        } else {
            viewHolder = (ViewHolder) convertView.getTag();
        }
        //设置数据后期写
        LinesManageData.DataBean bean = objects.get(position);
        viewHolder.tv_lines_sort.setText("专线" + StringUtil.changeNumberToChart(position + 1));
        viewHolder.tv_lines_staadd.setText(bean.getStartCity());
        viewHolder.tv_lines_endadd.setText(bean.getTargetCity());
        return convertView;
    }

    class ViewHolder {
        TextView tv_lines_sort;
        TextView tv_lines_staadd;
        TextView tv_lines_endadd;
        TextView tv_lines_totaldistance;

    }
}
